//相关业务逻辑
$(function(){
	page.bind();
});

var param="";
var page={//页面总变量
		bind:function(){
			$(".buttonPage").bind("click",function(){
				var text=$(this).text();
				if('员工达成率看板'==text){
					param='reachParam';
				}
				page.getWorkShpBtn();
			});
		},
		getWorkShpBtn:function(){
			$.ajax({
				url:'../workshop/getWorkshopName',
				success:function(data){
					if(data.result){
						data=data.data;
						html="";
						for(var i=0;i<data.length;i++){
							html+="<button>"+data[i]+"</button><br/>"
						}
						$("#workShop").html(html);
						$("#workShop button").addClass("btn-warning btn radius btn-block");
						page.btnBind();
					  }else{
						  layAlert(data.info);
					  }
					}
			});
		},
		btnBind:function(){
			$("#workShop button").bind("click",function(){
			   var workShop=$(this).text();
			   $.ajax({
					url:'../pageParam/setReachParam',
					data:{
						'reachParam':workShop
					},
					success:function(data){
						if(!data.result){
							console.log("员工达成率看板设置车间失败");
						}
					}
				});
			})
		}
		
}





//封裝alert提示框
function layAlert(str){
	layer.alert(str, {
		  skin: 'layui-layer-lan' //样式类名
		  ,closeBtn: 1
		});
}
